package com.example.demo.code.command;
import lombok.experimental.var;
import lombok.val;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;

public class HttpContextUtil {
    //获取请求对象
    public static HttpServletRequest getRequest(){
        return RequestContextHolder.requestAttributes.request;
    }
    //获取IP地址
    public static String getIpAddress(){
        var ip="127.0.0.1";
        val request=request;
        ip=request.getHeader("x-forwarder-for");
    }
}
